{extend name="base" /}
<!-- page specific plugin styles -->
{block name="inline-styles"}
{/block}
<!-- PAGE CONTENT BEGINS -->
{block name="content"}
<div class="page js_show">
    <div class="page__bd" style="height:100%;">
        <div class="weui-tab">
            <div class="weui-navbar">
                <a class="weui-navbar__item" href="{:url('Index/agent_team')}">
                    分销代理
                </a>
                <a class="weui-navbar__item weui-bar__item_on" href="{:url('Index/agent_personal')}">
                    直属代理(<span id='count'></span>)
                </a>
            </div>
            <div class="weui-tab__panel" style="padding-bottom:50px;">
               <div class="weui-panel" id="listData">
                        
               </div>
            </div>
            <div class="weui-tabbar" >
                <a href="{:url('Index/home')}" class="weui-tabbar__item ">
                    <div class="weui-tabbar__icon">
                        <i class="fa fa-home"></i>
                    </div>
                    <p class="weui-tabbar__label">主页</p>
                </a>
                <a href="{:url('Index/goods')}" class="weui-tabbar__item">
                    <div class="weui-tabbar__icon">
                        <i class="fa fa-list"></i>
                    </div>
                    <p class="weui-tabbar__label">下单</p>
                </a>
            </div>
        </div>
        
    </div>
</div>
{/block}
<!-- PAGE CONTENT ENDS -->
<!-- inline scripts related to this page -->
{block name="related-scripts"}
<script type="text/javascript">
    $.ajax({
        url: '/api/v1/team/lists_zhishu',
        type: 'POST',
        dataType: 'json',
    })
    .done(function(json) {
        console.log("success");
        renderData("#listData",json.data);
        $('#count').html(json.data.length)
    })
    .fail(function() {
        console.log("error");
    })
    .always(function() {
        console.log("complete");
    });

    // 渲染列表
    function renderData(_elment,_data){
        for(var i= 0; i<_data.length;i++){
        	var href ="{:url('Index/agent_sub')}?sub_id="+_data[i].id;
            var _item =
             '<a class="weui-cell weui-cell_access" href="'+href+'">\
                <div class="weui-cell__hd">\
                    <img src="'+_data[i].avatar+'" alt="" width="40" height="40" style="border-radius:50%">\
                </div>\
                <div class="weui-cell__bd">\
                    <div class="weui-cell__title">'+_data[i].name+'</div>\
                </div>\
                <div class="weui-cell__ft">\
	                <div class="weui-cell__title">分销代理:'+_data[i].sub_count+'&nbsp&nbsp;</div>\
	                <div class="weui-cell__title">直属代理:'+_data[i].direct_count+'&nbsp;&nbsp;</div>\
                </div>\
            </a>';

            $(_elment).append(_item);
        }

    }


//重置浏览器回退链接
browserBack("home.html");
</script>
{/block}